﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace ResUma
{
    public partial class TipPrezentaRezumatFrm : FrmRezumat
    {
        private int selID = 0;
        public TipPrezentaRezumatFrm(ModuleClass mc,int _selID):base(mc)
        {
            InitializeComponent();
            selID = _selID;

            formatTipSporBindingSource.List.Add(new FormatTipSpor("Prezenta", "P"));
            formatTipSporBindingSource.List.Add(new FormatTipSpor("Concediu Odihna", "O"));
            formatTipSporBindingSource.List.Add(new FormatTipSpor("Nemotivate", "N"));
            formatTipSporBindingSource.List.Add(new FormatTipSpor("Altele", "X"));

            timpBazaTipBindingSource.List.Add(new TimpBazaTip("Ore", 0, "O"));
            timpBazaTipBindingSource.List.Add(new TimpBazaTip("Zile", 1, "Z"));
            timpBazaTipBindingSource.List.Add(new TimpBazaTip("Valoare", 2, "V"));

            eSRPDataSet.TipPrezenta.InclusCASColumn.DefaultValue = true;
            eSRPDataSet.TipPrezenta.ProcentBazaColumn.DefaultValue = 0;
            eSRPDataSet.TipPrezenta.CodUnitateColumn.DefaultValue = ModuleInfo.CodUnitate;
            eSRPDataSet.TipPrezenta.IdOpContabilaColumn.DefaultValue = 0;
        }

        private void TipPrezentaRezumatFrm_Load(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = DeschideConexiune(workConnString);
                this.tipPrezentaTableAdapter.Connection = con;
                this.tipPrezentaTableAdapter.Fill(this.eSRPDataSet.TipPrezenta, ModuleInfo.CodUnitate);
                InchideConexiune(con);
            }
            catch (Exception ex)
            {
                MessageBoxFrm mbt = new MessageBoxFrm("Eroare", ex.Message, String.Empty, MessageBoxFrm.ImaginiMB.StopIcon, tipPrezentaTableAdapter);
                mbt.AddButton("Ieşire", 70, mbt.MessageBoxFrm_Click_Yes);
                mbt.ShowDialog();
                Close();
                return;
            }

            AddBindingSource(tipPrezentaBindingSource);
            AddTableAdaptor(tipPrezentaTableAdapter.Adapter);

        }
    }

    [Serializable]
    public class TimpBazaTip
    {
        public TimpBazaTip(String nume, Int16 tag, String _type)
        {
            _Name = nume;
            _Tag = tag;
            _Type = _type;
        }

        private String _Name = String.Empty;
        [System.ComponentModel.Bindable(true)]
        public String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }
        private Int16 _Tag = 0;
        [System.ComponentModel.Bindable(true)]
        public Int16 Tag
        {
            get
            {
                return _Tag;
            }
            set
            {
                _Tag = value;
            }
        }
        private String _Type = "T";
        [System.ComponentModel.Bindable(true)]
        public String Type
        {
            get
            {
                return _Type;
            }
            set
            {
                _Type = value;
            }
        }

    }



}
